﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModelLayer;

namespace DBLayer
{
    public class ShowDBDummy : IShowDB
    {
        private Show testShow;
        private int currentId = 0;

        public ShowDBDummy()
        {
            testShow = CreateTestShow();
        }

        public Show CreateTestShow()
        {
            string[] actors = { "actor1", "actor2", "actor3" };
            DateTime d1 = new DateTime(2012, 10, 15);
            DateTime d2 = new DateTime(2012, 11, 20);
            Movie m = new Movie(true, "Title", 200, "actors", 15, "Blargh", "PG:13", "Steven Spegepølse", "Komedie", "Swahili", 9001, "Gerbal Rentals", d1, d2);
            Cinema c = new Cinema("Biffen500", "Testvej 13");
            Room r = new Room("1", 100, c);
            Show s = new Show(m, r, d1, 70);

            return s;
        }
        public int InsertShow(Show s)
        {
            if (s == null)
            {
                throw new ArgumentNullException();
            }
            else
            {
                testShow = s;
                currentId++;
                testShow.Id = currentId;
                return currentId;
            }
        }

        public Show GetShow(int id)
        {
            if (testShow == null)
            {
                return null;
            }
            else if (testShow.Id == id)
            {
                return testShow;
            }
            else
            {
                return null;
            }
        }

        public Show GetShow(DateTime dateTime)
        {
            if (testShow == null)
            {
                return null;
            }
            else if (testShow.DateTime.Equals(dateTime))
            {
                return testShow;
            }
            else
            {
                return null;
            }
        }

        public int DeleteShow(int id)
        {
            if (testShow.Id == id)
            {
                testShow = null;
            }
            else
            {
                // do nothing
            }
            return 1;
        }

        public int UpdateShow(Show s)
        {
            if (s.Id.Equals(testShow.Id))
            {
                testShow = s;
            }
            else
            {
                // do nothing
            }
            return 1;
        }

        public List<Show> FindShowsByDate(DateTime d)
        {
            List<Show> ShowList = new List<Show>();
            ShowList.Add(testShow);
            return ShowList;
        }

        public List<Show> GetShows(Movie movie)
        {
            return new List<Show>();
        }

        public List<Show> GetShows(DateTime a, DateTime b)
        {
            List<Show> ShowList = new List<Show>();
            return ShowList;
        }


    }
}
